package engine;

import java.util.List;

public class AI{
	static final int FOLD = 0;
	static final int CHECK = 1;
	static final int CALL = 2;
	static final int RAISE = 3;
	static final int ALLIN = 4;
	static final int ALLINRAISE = 5;
	public Game game;
	// konstruktor
	public  AI(Game game){
		this.game = game;
	}

	public void getAction(Player player){
		List<Integer> actions = game.getAvailableActions();
		int rNr = (int) Math.floor(Math.random()*actions.size());
		chat(player);
		switch(actions.get(rNr)){
		case (FOLD):
			player.fold();
		break;
		case (CHECK):
			player.checkCall();
		break;
		case (CALL):
			player.checkCall();
		break;
		case (RAISE):
			player.raise();
		break;
		case (ALLIN):
			player.raise();
		break;
		case (-1):
			System.err.println("bot can't do anything :)");
		break;
		}
	}

	public void chat(Player player){
		int rNr = (int) Math.floor(Math.random()*100);
		String[] lines = {"Roses are unicorns,violets are green, welcome to the party, I'm Charlie Sheen",
				"get on your bike",
				"is this how you play?",
				"Aces.. cool",
				"Nice run..",
				"Nice hand",
				"What you've got? AK?",
				"bring on more humans!",
				"this game is eaasy",
				"lol",
				":)",
				"stack'em, stack'em, stack'em... TO THE TOP!!",
				"What? What? I couldn't hear you over the sound of how awesome I am!",
				"Ship it, Holla!",
				"I can do this aaaaalllll day!",
				"This is Pokaaaaa..., I bet 300!!!",
				"Mess with the best, lose like rest.",
				"You had it coming.",
				"Give me my money!!!",
				"Fold and live to fold again",
				"Just play every hand, you can't miss them all",
				"I need to play in a bigger game, people will play any trash at this table",
				"Why would you raise with AK?!? AK isnt really a hand!",
				"72 is garbage, but if they're suited, you gotta play them!",
				"I'm winning",
				"BANG-BANG",
				"Resistance is futile. I will take your money one way or another."
		};
		if (rNr < 5) {
			synchronized(game.messenger){
				game.messenger.callAction("sendToChat(\"" + player.name + "\",\"" + lines[(int) Math.floor(Math.random()*lines.length)]+"\")");
			}
			
		}
	}
}